package handler

import (
	"bytes"
	"encoding/json"
	"log"
	"net/http"

	"github.com/gin-gonic/gin"
)

const URL string = "http://localhost:3000/register"
const HOST string = "localhost"
const PORT string = "3001"

func (h *Handler) registerServise(c *gin.Context) {
	var data = map[string]string{
		"apiName":  "encryption",
		"protocol": "http",
		"host":     "localhost",
		"port":     "3001",
	}

	json_data, err := json.Marshal(data)

	if err != nil {
		log.Fatal(err)
	}

	res, err := http.Post(URL, "application/json", bytes.NewBuffer(json_data))

	if err != nil {
		panic(err)
	}

	defer res.Body.Close()

	var resp map[string]interface{}

	json.NewDecoder(res.Body).Decode(&resp)

	c.JSON(http.StatusOK, resp)
}
